﻿@model RepertorySystem.Models.AccountList
@Scripts.Render("~/bundles/jquery")
@{
    ViewBag.Title = "Delete";
}

<h2>删除 <span class="glyphicon glyphicon-trash" style="color: rgb(69, 63, 63);"></span></h2>

<h3>确认要删除该条记录吗？</h3>
<div>
    <hr />
    <dl class="dl-horizontal">
        <dt>
            @Html.DisplayNameFor(model => model.Time)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.Time)
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.Category)
        </dt>

        <dd class="@Html.DisplayFor(model => model.Category)category">
            <script type="text/javascript">
                $(".0category").text("出库");
                $(".1category").text("入库");
            </script>
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.Book_Id)
        </dt>

        <dd class="@Model.Book_Id">
                @{
                    //获取端口
                    IServiceProvider provider = (IServiceProvider)HttpContext.Current;
                    HttpWorkerRequest request = (HttpWorkerRequest)provider.GetService(typeof(HttpWorkerRequest));
                    var port = HttpContext.Current.Request.Url.Port;
                }
                @if (@Html.DisplayFor(modelItem => Model.Book_Id) != null) {

                    <script type="text/javascript">
                        var bookId = @Html.DisplayFor(modelItem => Model.Book_Id);
                        $.ajax({
                            url: "http://localhost:"+@port+"/api/Books/"+bookId,
                            type:"get",
                            success: function (result) {
                                $(".@Model.Book_Id").text(result.Name);
                            },
                            error: function (msg) {
                                console.log(msg);
                            }

                        });

                    </script>
                }
</dd>

        <dt>
            @Html.DisplayNameFor(model => model.Book_Number)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.Book_Number)
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.Price)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.Price)
        </dd>

    </dl>

    @using (Html.BeginForm()) {
        @Html.AntiForgeryToken()

        <div class="form-actions no-color">
            <input type="submit" value="删除" class="btn btn-default" style=" background-color: #f2dede;border-color: #eed3d7;" /> |
            @Html.ActionLink("返回账目列表", "Index", null, new { @class = "btn btn-default" })
        </div>
    }
</div>
